
/**
 * 取字典
 * @param dict 字典类型
 */
export const  getDict=(dictType) =>{
    let dict;
    if (dictType.indexOf('.')>-1){
        dict = uni.getStorageSync('userInfo').dicts ? uni.getStorageSync('userInfo').dicts[dictType.split(".")[0]] : [];
        if (!dict) return [];
        if (!dict.children) return [];
        return getDictChildren(dict,dictType.split("."),1)
    }else {
        dict = uni.getStorageSync('userInfo').dicts ? uni.getStorageSync('userInfo').dicts[dictType] : [];
        if (!dict) return [];
        if (!dict.children) return [];
        return dict.children;
    }
}
    /**
     * 返回字典的下一级
     */
export const  getDictChildren=(dict, arr, current)=> {
        while (current<arr.length){
            //在当前dictchildren找到arr[cur]匹配的
            dict=getChildren(dict,arr[current]);
            current++;
        }
        // console.log(dict,"las")
        return dict?dict.children:[{dictName: "其他"}];
    }
export const  getChildren=(dict,dictName)=> {
    for (let i = 0; i < dict.children.length; i++) {
        if (dict && dict.children && dict.children[i].dictName === dictName) {
            return dict.children[i];
        }
    }
}